﻿# module for login gateway
# Author:titan52
#
# create on 2015-10-15 23:20:11

class Login:
    def __init__(self):
        post_url = "http://10.3.8.211/"
        header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.2; rv:16.0) Gecko/20100101 Firefox/16.0','Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Connection':'keep-alive'}
        post_data = {'DDDDD':'2012010334','upass':'09090011','0MKKey':'','savePWD':'0'}
        post_data = urllib.urlencode(post_data)
        request = urllib2.Request(post_url,post_data,header)
        response = urllib2.urlopen(request)
        #html = response.read()
        #html = html.decode('gbk').encode(sys.getfilesystemencoding())
        '''
        try:
            req = urllib2.urlopen(post_url,data)
            #print req
            #response = urllib2.urlopen(request)
        except:
            print 'Unable to connect to 10.3.8.211'
            #return False
        pat = 'mcode'
        result = re.findall(pat,req.read())
        if result:
            print 'successful.'
            #return Ture
        '''
